﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using automobili_data;
using automobili_data.interfaces;

namespace automobili_gui.Admin
{
    public partial class DefParametaraAutomobila : System.Web.UI.Page
    {
        
        ArrayList mod, mar, gor, kar;
        protected void Page_Load (object sender, EventArgs e)
        {
            Privilegije p = SessionUtils.getCurrentPrivileges();
          //  if (!Page.IsPostBack)
          //  {
            if (p.DefNabParAuto_a == 1)
            {
                dohvatiModele();
                dohvatiMarke();
                dohvatiGorivo();
                dohvatiKaroseriju();
            }
          //  }
        }
        private void dohvatiModele ()
        {
            mod = AutomobiliDataManager.instance.dohvatiModele();
            mod.Insert(0, "");
            modelLista.DataSource = mod;
            modelLista.DataBind();

        }

        private void dohvatiMarke ()
        {
            mar = AutomobiliDataManager.instance.dohvatiMarke();
            mar.Insert(0, "");
            markaLista.DataSource = mar;
            markaLista.DataBind();
        }

        private void dohvatiGorivo ()
        {
            gor = AutomobiliDataManager.instance.dohvatiGorivo();
            gor.Insert(0, "");
            gorivoLista.DataSource = gor;
            gorivoLista.DataBind();

        }

        private void dohvatiKaroseriju ()
        {
            kar = AutomobiliDataManager.instance.dohvatiKaroseriju();
            kar.Insert(0, "");
            karoserijaLista.DataSource = kar;
            karoserijaLista.DataBind();

        }

        protected void Button1_Click (object sender, EventArgs e)
        {
            if (TextBox1.Text != "")
            {
                AutomobiliDataManager.instance.dodajMarku(TextBox1.Text);
                TextBox1.Text = "";
                dohvatiMarke();
            }
        }

        protected void Button2_Click (object sender, EventArgs e)
        {
            if (TextBox2.Text != "")
            {
                AutomobiliDataManager.instance.dodajModel(TextBox2.Text);
                TextBox2.Text = "";
                dohvatiModele();
            }
        }

        protected void Button3_Click (object sender, EventArgs e)
        {
            if (TextBox3.Text != "")
            {
                AutomobiliDataManager.instance.dodajGorivo(TextBox3.Text);
                TextBox3.Text = "";
                dohvatiGorivo();
            }
        }

        protected void Button4_Click (object sender, EventArgs e)
        {
            if (TextBox4.Text != "")
            {
                AutomobiliDataManager.instance.dodajKaroseriju(TextBox4.Text);
                TextBox4.Text = "";
                dohvatiKaroseriju();
            }
        }





     
    }
}